package com.xsf.jieyou.cloud.producer;

import com.xsf.jieyou.cloud.api.MessageService;
import com.xsf.jieyou.cloud.message.MessageSource;
import com.xsf.jieyou.commons.entity.UserLog;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;

/**
 * 消息生产者 服务，Dubbo接口实现类
 *
 * @author xsf
 * @version v1.0.0
 * @date 2019/11/16 0016 0:04
 * @see com.xsf.jieyou.cloud.producer
 **/
@Service(version = "1.0.0")
public class MessageServiceImpl implements MessageService {
    @Resource
    private MessageSource source;

    /**
     * 管理登录日志
     *
     * @param userLog {@link UserLog}
     * @return {@code boolean}
     */
    @Override
    public boolean sendTbUserLog(UserLog userLog) {
        return this.source.adminLoginLog().send(MessageBuilder.withPayload(userLog).build());
    }
}